const readline = require('readline-sync');
let user = 'zhangsan', password = 123, money = 500;
let flag = false;//控制登陆状态
for (let i = 2; i >= 0; i--) {
    console.log('请输入账号名');
    let username = readline.question();
    console.log('请输入密码');
    let pwd = readline.question() - 0;
    if (username == user && pwd == password) {
        //登陆成功
        flag = true;
        break;
    } else {
        console.log('账号或密码错误');
    }
}


while (flag) {
    console.log('请选择操作功能：1.存 2.取 3.查 4.退');
    let opt = readline.question() - 0;
    switch (opt) {
        case 1://存
            console.log('请输入存钱金额');
            let save = readline.question() - 0;
            money += save;//存入金额
            console.log('余额：' + money);
            break;
        case 2://取
            console.log('请输入取钱金额');
            let draw = readline.question() - 0;
            if (draw <= money) {//钱够，可以取
                money -= draw;
            } else {
                console.log('余额不足');
            }
            console.log('余额：' + money);
            break;
        case 3://查询余额
            console.log('余额：' + money);
            break;
        case 4://退
            flag = false;
            console.log(886);
            break;
        default:
            console.log('暂无此的功能');

    }

}
